﻿Imports System.Collections.Generic
Public Class KhuVucDAO
    'phuong thuc lay danh sach dua vao ma mon

    Public Shared Function LayDanhSachKhuVuc() As List(Of CKhuVuc)
        Dim kq As List(Of CKhuVuc) = New List(Of CKhuVuc)
        Dim str As String = String.Format("SELECT * from KhuVuc")
        Dim dt As DataTable = CKetNoi.ExecQuery(str)
        For Each i As DataRow In dt.Rows
            Dim khuvuc As New CKhuVuc
            khuvuc.MaKV = i("MaKV")
            khuvuc.TenKV = i("TenKV")
            kq.Add(khuvuc)
        Next
        Return kq
    End Function
    Public Shared Function Insert(ByVal b As CKhuVuc) As Integer
        Dim sql As String = String.Format("INSERT INTO KhuVuc(MaKV,TenKV) VALUES('{0}','{1}')", b.MaKV, b.TenKV)
        Return CKetNoi.ExecnonQuery(sql)

    End Function
    Public Shared Function Delete(ByVal makv As String) As Integer
        Dim sql As String = String.Format("Delete from KhuVuc where MaKV='{0}'", makv)
        Return CKetNoi.ExecnonQuery(sql)

    End Function
    Public Shared Function Update(ByVal b As CKhuVuc) As Integer
        Dim sql As String = String.Format("Update KhuVuc set TenKV='{0}'", b.TenKV)
        Return CKetNoi.ExecnonQuery(sql)

    End Function
End Class
